<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Live memorial day</title>
</head>
<body>
	<span>请输入您的生日：</span>
	<input type="date" id="birthday" />
	<button onclick="doClick()">查看结果</button>
	<p id="hint"></p>
</body>
<script>
	function doClick() {
		let value = document.querySelector("#birthday").value;
		let birthday = new Date(value);
		if (isNaN(birthday)) {
			console.log('年月日请填写完整');
			return ;
		}
		let birthdayMilli = birthday.getTime();
		let now = new Date();
		let nowMilli = now.getTime();
		let pastDays = parseInt((nowMilli - birthdayMilli) / 1000 / 60 / 60 / 24);
		
		let hint = document.querySelector("#hint");
		hint.innHTML = "";
		hint.innerHTML = "从 " + formatDate(birthday) + " 到今天为止，您一共经历了" + pastDays + "天；";
		
		let loop = parseInt(pastDays / 10000) + 1;
		for (var i = 0; i < loop; i++) {
			hint.innerHTML = hint.innerHTML + " \n "
			let tenThousandDay = new Date(birthdayMilli + (10000 * loop * 24 * 60 * 60 * 1000));
			hint.innerHTML = hint.innerHTML + 10000 * loop + "天纪念日：" + formatDate(tenThousandDay);
		}
	}
	
	function formatDate(date) {
		return date.getFullYear() + "年" + (date.getMonth() + 1) + "月" + date.getDate() + "日";
	}
</script>
</html>